<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>coupledatepicker demo </title>
<link type="text/css" rel="stylesheet"  href="../highlight/shCore.css"/>
<link type="text/css" rel="stylesheet" href="../style/avalon.doc.css"/>
<script src="../highlight/shCore.js"></script>
<script src="../avalon.js"></script>
<style>
    .syntaxhighlighter {
        *z-index: -1;
    }
</style>
</head>
<body>
    <div class="wrapper">
        <h1>coupledatepicker demo</h1>
        <div class="demo-show" ms-controller="demo">
            <fieldset>
                <legend>双日历框 配置日期的显示规则和解析规则</legend>
                <div ms-widget="coupledatepicker, a, $aOpts"></div>
            </fieldset>
            <script> 
                require(["datepicker/avalon.coupledatepicker"], function(avalon) {
                    var model = avalon.define("demo", function(vm) {
                        vm.$aOpts = {
                            parseDate : function(str){
                                var reg = "^(\\d{4})" + "年"+ "(\\d{1,2})"+ "月" +"(\\d{1,2})"+ "日$";
                                reg = new RegExp(reg);
                                var x = str.match(reg);
                                return x ? new Date(x[1],x[2] * 1 -1 , x[3]) : null;
                            },
                            formatDate : function(date){
                                var separator = this.separator,
                                    year = date.getFullYear(),
                                    month = date.getMonth(),
                                    day = date.getDate();
                                return year + "年" + this.formatNum(month + 1 , 2) + "月" + this.formatNum(day , 2) + "日";
                            }
                        }
                    })
                    avalon.scan();
                })
            </script>
        </div>
        <div ms-skip>
            <pre class="brush: js; html-script: true; gutter: false; toolbar: false">
                &lt;!DOCTYPE HTML&gt;
                &lt;html&gt;
                &lt;head&gt;
                    &lt;meta charset='utf-8'/&gt;
                    &lt;title&gt;coupledatepicker demo&lt;/title&gt;
                    &lt;script src='avalon.js'&gt;&lt;/script&gt;
                &lt;/head&gt;
                &lt;body&gt;
                    &lt;div class="demo-show" ms-controller="demo"&gt;
                        &lt;fieldset&gt;
                            &lt;legend&gt;双日历框 配置日期的显示规则和解析规则&lt;/legend&gt;
                            &lt;div ms-widget="coupledatepicker, a, $aOpts"&gt;&lt;/div&gt;
                        &lt;/fieldset&gt;
                        &lt;script&gt; 
                            require(["datepicker/avalon.coupledatepicker"], function(avalon) {
                                var model = avalon.define("demo", function(vm) {
                                    vm.$aOpts = {
                                        parseDate : function(str){
                                            var reg = "^(\\d{4})" + "年"+ "(\\d{1,2})"+ "月" +"(\\d{1,2})"+ "日$";
                                            reg = new RegExp(reg);
                                            var x = str.match(reg);
                                            return x ? new Date(x[1],x[2] * 1 -1 , x[3]) : null;
                                        },
                                        formatDate : function(date){
                                            var separator = this.separator,
                                                year = date.getFullYear(),
                                                month = date.getMonth(),
                                                day = date.getDate();
                                            return year + "年" + this.formatNum(month + 1 , 2) + "月" + this.formatNum(day , 2) + "日";
                                        }
                                    }
                                })
                                avalon.scan();
                            })
                        &lt;/script&gt;
                    &lt;/div&gt;
                &lt;/body&gt;
                &lt;/html&gt;
            </pre>
        </div>
    </div>
</body>
</html>